﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TtfLibrary
{
    [TtfStructure]
    public class TtfPanose
    {
        public byte FamilyType;
        public byte SerifStyle;
        public byte Weight;
        public byte Proportion;
        public byte Contrast;
        public byte StrokeVariation;
        public byte ArmStyle;
        public byte Letterform;
        public byte Midline;
        public byte XHeight;
    }

    public class OttOS2: IAfterRead
    {
        public UInt16 Version;
        public Int16 XAvgCharWidth;
        public UInt16 UsWeightClass;
        public UInt16 UsWidthClass;
        public UInt16 FsType;
        public Int16 YSubscriptXSize;
        public Int16 YSubscriptYSize;
        public Int16 YSubscriptXOffset;
        public Int16 YSubscriptYOffset;
        public Int16 YSuperscriptXSize;
        public Int16 YSuperscriptYSize;
        public Int16 YSuperscriptXOffset;
        public Int16 YSuperscriptYOffset;
        public Int16 YStrikeoutSize;
        public Int16 YStrikeoutPosition;
        public Int16 SFamilyClass;
        public TtfPanose Panose = new TtfPanose();
        public UInt32 UlUnicodeRange1;
        public UInt32 UlUnicodeRange2;
        public UInt32 UlUnicodeRange3;
        public UInt32 UlUnicodeRange4;
        public char[] AchVendId = new char[4];
        public UInt16 FsSelection;
        public UInt16 UsFirstCharIndex;
        public UInt16 UsLastCharIndex;
        public Int16 STypoAscender;
        public Int16 STypoDescender;
        public Int16 STypoLineGap;
        public UInt16 UsWinAscent;
        public UInt16 UsWinDescent;
        public UInt32 UlCodePageRange1;
        public UInt32 UlCodePageRange2;
        [TtfPartAttribute("v2")]
        public Int16 SxHeight;
        public Int16 SCapHeight;
        public UInt16 UsDefaultChar;
        public UInt16 UsBreakChar;
        public UInt16 UsMaxContext;

        public void AfterRead(TtfStructureReader reader, int startOffset)
        {
            if (this.Version >= 2)
                reader.Read(this, new[] { "v2" });
        }
    }
}
